package pf.springBoot.springBootSSO;

import java.sql.DriverManager;
import java.sql.SQLException;

//import javax.servlet.ServletContext;
//import javax.servlet.ServletException;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

//import net.sourceforge.jtds.jdbc.Driver;
import pf.java.pfHelper.config.PFDataHelper;
import pf.springBoot.springBootSSO.springBootSSOApp;

//import pf.java.pfHelper.IocRegistration;
//import pf.java.pfHelper.PFCaching;
//import org.springframework.context.event.ContextRefreshedEvent;
//import org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver;
//import org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration;
//import org.springframework.boot.context.ApplicationPidFileWriter;
//import org.springframework.context.ApplicationContext;
//import org.springframework.context.ApplicationListener;
//import org.springframework.context.annotation.Bean;
/**
 * Hello world!
 *
 */
//@SpringBootApplication(exclude=ErrorMvcAutoConfiguration.class)
@SpringBootApplication
@ComponentScan(basePackages = {
		//"pf.springBoot.springBootSSO.*"
		"pf.springBoot.springBootSSO.configuration"
		,"pf.springBoot.springBootSSO.configuration.*"
		,"pf.springBoot.springBootSSO.dal"
		,"pf.springBoot.springBootSSO.dal.*"
		,"pf.springBoot.springBootSSO.service"
		,"pf.springBoot.springBootSSO.controller"
		,"pf.springBoot.springBootSSO.controller.*"
		,"pf.springBoot.springBootSSO.apiController"
		,"com.perfect99.right.amsweb"
		,"pf.springBoot.springBootSSO.oAuth"
		,"pf.java.pfHelper.config"
		,"pf.java.pfHelperMvc.config"
		})
public class springBootSSOApp
{
//	public static ApplicationContext _context;
//	public static Boolean started=false;
    public static void main( String[] args )
    {
    	PFDataHelper.SetConfigMapper(new pf.springBoot.springBootSSO.configuration.PFConfigMapper());
    	try {
			DriverManager.registerDriver(new net.sourceforge.jtds.jdbc.Driver());
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    	SpringApplication.run(springBootSSOApp.class, args);
    	
   	    //_context=SpringApplication.run(springBootMetabaseLoginApp.class, args);
//    	started=true;
//		//new PFCaching();		

//  SpringApplication application = new SpringApplication(springBootMetabaseLoginApp.class);
//  application.addListeners(new ApplicationPidFileWriter());
//  application.run(args);
		
    }
//    public static ApplicationContext get() {
//    	return _context;
//    }
    
//        @Override
//        public void onApplicationEvent(ContextRefreshedEvent event) {
//        	IocRegistration.setApplicationContext(event.getApplicationContext());
//            
//        }
    
//	@Override
//    public void onStartup(ServletContext servletContext) throws ServletException {
//        super.onStartup(servletContext);
//        FilterRegistration.Dynamic localeFilter = servletContext.addFilter("encoding",
//               new CharacterEncodingFilter("UTF-8",true));
//        localeFilter.addMappingForUrlPatterns(null, false, "/*");
//    }
//    @Bean
//    public SpringResourceTemplateResolver templateResolver() {
//        // SpringResourceTemplateResolver automatically integrates with Spring's own
//        // resource resolution infrastructure, which is highly recommended.
//        SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
//        templateResolver.setApplicationContext(this.applicationContext);
//        templateResolver.setPrefix("/WEB-INF/templates/");
//        templateResolver.setSuffix(".html");
//        // HTML is the default value, added here for the sake of clarity.
//        templateResolver.setTemplateMode(TemplateMode.HTML);
//        // Template cache is true by default. Set to false if you want
//        // templates to be automatically updated when modified.
//        templateResolver.setCacheable(true);
//        templateResolver.setCharacterEncoding("UTF-8");
//        return templateResolver;
//    }
}
